import React, { Component } from 'react'

interface IState {
    name?: string
}

export default class App extends Component<any, IState> {
    state = { 
        name: "张无忌"
    }
    txtRef = React.createRef<HTMLInputElement>();
    render() {
        return (
            <div>
                App-{this.state.name}
                <button onClick={() => {
                    this.setState({
                        name: "周芷若"
                    })
                }}>修改</button> <br />
                <input ref={this.txtRef}/><button onClick={() =>{
                    this.setState({
                        name: (this.txtRef.current as HTMLInputElement).value
                    })
                }}>打印</button>
            </div>
        )
    }
}
